<?php

require_once dirname(__FILE__) . '/../../Extension/Params.php';
require_once dirname(__FILE__) . '/TextValues.php';

class Rams_Extension_GeoParams extends Raws_Extension_Params
{
  
  // protected $_rootNamespace = 'raws';
  // protected $_rootElement = 'params';

    # child elements of the params element
    protected $_volume = null;
    protected $_hits = null;
    protected $_updated = null;
    protected $_last_modified = null;

    protected $_domain = null;
    protected $_country = null;
    protected $_region = null;
    protected $_city = null;
    protected $_host = null;

    public function __construct($volume = null, $hits = null, $updated = null) 
    {
        parent::__construct();
        $this->setVolume($volume);
        $this->setHits($hits);
        $this->setUpdated($updated);
    }
    
    /**
     * Retrieves a DOMElement which corresponds to this element and all
     * child properties.  This is used to build an entry back into a DOM
     * and eventually XML text for application storage/persistence.
     *
     * @param DOMDocument $doc The DOMDocument used to construct DOMElements
     * @return DOMElement The DOMElement representing this element and all
     *          child properties.
     */
    public function getDOM($doc = NULL, $majorVersion = 1, $minorVersion = NULL)
    {
        $element = parent::getDOM($doc);
        if ($this->_volume !== null) {
            $element->appendChild($this->_volume->getDOM($element->ownerDocument));
        }
        if ($this->_hits !== null) {
            $element->appendChild($this->_hits->getDOM($element->ownerDocument));
        }
        if ($this->_updated !== null) {
            $element->appendChild($this->_updated->getDOM($element->ownerDocument));
        }
        if ($this->_last_modified != null) {
          $element->appendChild($this->_last_modified->getDOM($element->ownerDocument));
        }
        if ($this->_domain != null) {
          $element->appendChild($this->_domain->getDOM($element->ownerDocument));
        }
        if ($this->_country != null) {
          $element->appendChild($this->_country->getDOM($element->ownerDocument));
        }
        if ($this->_region != null) {
          $element->appendChild($this->_region->getDOM($element->ownerDocument));
        }
        if ($this->_city != null) {
          $element->appendChild($this->_city->getDOM($element->ownerDocument));
        }
        if ($this->_host != null) {
          $element->appendChild($this->_host->getDOM($element->ownerDocument));
        }
        
        return $element;
    }

    /**
     * Creates individual Entry objects of the appropriate type and
     * stores them as members of this entry based upon DOM data.
     *
     * @param DOMNode $child The DOMNode to process
     */
    protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
        
        switch ($absoluteNodeName) {
            case $this->lookupNamespace('raws') . ':' . 'volume'; 
                $volume = new Rams_Extension_Volume();
                $volume->transferFromDOM($child);
                $this->_volume = $volume;
                break;
            case $this->lookupNamespace('raws') . ':' . 'hits'; 
                $hits = new Rams_Extension_Hits();
                $hits->transferFromDOM($child);
                $this->_hits = $hits;
                break;
            case $this->lookupNamespace('raws') . ':' . 'updated'; 
                $updated = new Rams_Extension_Updated();
                $updated->transferFromDOM($child);
                $this->_updated = $updated;
                break;
            case $this->lookupNamespace('raws') . ':' . 'last_modified'; 
                $last_modified = new Rams_Extension_LastModified();
                $last_modified->transferFromDOM($child);
                $this->_last_modified = $last_modified;
                break;
            case $this->lookupNamespace('raws') . ':' . 'domain'; 
                $domain = new Rams_Extension_Domain();
                $domain->transferFromDOM($child);
                $this->_domain = $domain;
                break;
            case $this->lookupNamespace('raws') . ':' . 'country'; 
                $country = new Rams_Extension_Country();
                $country->transferFromDOM($child);
                $this->_country = $country;
                break;
            case $this->lookupNamespace('raws') . ':' . 'region'; 
                $region = new Rams_Extension_Region();
                $region->transferFromDOM($child);
                $this->_region = $region;
                break;
            case $this->lookupNamespace('raws') . ':' . 'city'; 
                $city = new Rams_Extension_City();
                $city->transferFromDOM($child);
                $this->_city = $city;
                break;
            case $this->lookupNamespace('raws') . ':' . 'host'; 
                $host = new Rams_Extension_Host();
                $host->transferFromDOM($child);
                $this->_host = $host;
                break;
              
            default:
                parent::takeChildFromDOM($child);
                break;
        }
    }
    
    public function getVolume()
    {
        return $this->_volume;
    }

    public function setVolume($value)
    {
        $this->_volume = $value;
        return $this;
    }

    public function getHits()
    {
        return $this->_hits;
    }

    public function setHits($value)
    {
        $this->_hits = $value;
        return $this;
    }

    public function getUpdated()
    {
        return $this->_updated;
    }

    public function setUpdated($value)
    {
        $this->_updated = $value;
        return $this;
    }

    public function getLastModified()
    {
        return $this->_last_modified;
    }

    public function setLastModified($value)
    {
        $this->_last_modified = $value;
        return $this;
    }

    public function getDomain()
    {
        return $this->_domain;
    }

    public function setDomain($value)
    {
        $this->_domain = $value;
        return $this;
    }

    public function getCountry()
    {
        return $this->_country;
    }

    public function setCountry($value)
    {
        $this->_country = $value;
        return $this;
    }

    public function getRegion()
    {
        return $this->_region;
    }

    public function setRegion($value)
    {
        $this->_region = $value;
        return $this;
    }

    public function getCity()
    {
        return $this->_city;
    }

    public function setCity($value)
    {
        $this->_city = $value;
        return $this;
    }

    public function getHost()
    {
        return $this->_host;
    }

    public function setHost($value)
    {
        $this->_host = $value;
        return $this;
    }

}
